﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TCG.Engine.Effects;
using TCG.Engine.Core;
using TCG.Engine.Impacts;
using TCG.Engine.Libraries;

namespace TCG.Engine.Tests.HumanDeck
{
    [Effect("UnrelentingAssault")]
    public class UnrelentingAssaultEffect: OvertimeEffect, IDirectEffect
    {
        public UnrelentingAssaultEffect(): base(0)
        {

        }
        int counter;
        public void Execute(MoveContext mc)
        {
            counter = mc.ActivePlayer.Interaction.SelectMana();

            mc.Impacts.Add(new ApplyEffectImpact(this));
            mc.Impacts.Add(ImpactsFactory.CostMana(counter, TargerInfo.Self));
        }

        public override void EndMove(MoveContext mc)
        {
            if (counter >= 0)
            {
                counter--;
            }
            else
            {
                mc.ActivePlayer.Effects.Remove(this);
                return;
            }

            if (mc.Card.Info.Classes.Contains(HumanConsts.Classes.HumanTrooper))
            {
                mc.ActivePlayer.Hand.Add(mc.Card);
                mc.ActivePlayer.Deck.Sideboard.Remove(mc.Card);
            }
        }

        public override void Apply(MoveContext mc)
        {
            mc.ActivePlayer.Effects.Add(this);
        }
    }
}
